###
# js_builder rake tasks
# @author Chris Scott
#

namespace :js_builder do 
    
    ###
    # @task build
    #
    desc "Build javascript libraries"
    task :build => :environment do  
        
        # alias arg "p" to "project"...tired of writing "project"
        ENV["project"] = ENV["p"] if !ENV["p"].nil? 
        
        if (ENV["project"].nil?)
            puts "Error -- undefined argument 'project'.  you must specify a project to build."
            exit(0)
        end
        puts "******************************************************************"
        puts "* JsBuilder::Project, building project '" + ENV["project"] + "'"
        puts "******************************************************************"
        
        builder = JsBuilder::Project.new(ENV["project"])                      
        builder.build
    end     
    
    ###
    # @task document
    #
    desc "Build javascript documentation"
    task :document => :environment do
        if (ENV["project"].nil?)
            puts "Error -- undefined argument 'project'.  you must specify a project to build."
            exit(0) 
        end
        puts "******************************************************************"
        puts "* JsBuilder::Documentor -- Javascript Documentation Generator"
        puts "******************************************************************"
        puts "-building documentation for project: " + ENV["project"] + '...' + "\n"
        
        documentor = JsBuilder::Documentor.new(ENV["project"])
        documentor.build        
    end
end
